home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_04 / saks / lns1a.h < prev    next >
C/C++ Source or Header  |  1994-02-09  |  609b  |  44 lines

  1.  
  2. ----------
  3.  
  4. Listing 4 - class definition for lns using a single pointer
  5.  
  6. //
  7. // lns1a.h - line number sequence interface
  8. //
  9. #ifndef LNS_H_INCLUDED
  10. #define LNS_H_INCLUDED
  11.  
  12. class lns
  13.     {
  14. public:
  15.     lns(unsigned n);
  16.     ~lns();
  17.     void add(unsigned n);
  18.     void print();
  19. private:
  20.     class node;
  21.     node *first;
  22.     };
  23.  
  24. class lns::node
  25.     {
  26. public:
  27.     node(unsigned n);
  28.     unsigned number;
  29.     node *next;
  30.     };
  31.  
  32. inline lns::node::node(unsigned n)
  33.     : number(n), next(0)
  34.     {
  35.     }
  36.  
  37. inline lns::lns(unsigned n)
  38.     {
  39.     first = new node(n);
  40.     }
  41.  
  42. #endif
  43.  
  44.